package org.shan;

import org.shan.security.core.authorize.AuthorizeConfigProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;

/**
 * Created by amanda.shan on 2019/3/19.
 */
@Configuration
public class DemoConfig {

    @Bean
    public AuthorizeConfigProvider provider(){
        return new AuthorizeConfigProvider() {
            @Override
            public boolean config(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry
                                          config) {
//                config
//                        .anyRequest()
//                        .antMatchers("/pre/**")
//                        .access("@rbacService.hasPermission(request,authentication)");

                            // /db 路径下的url，需要同时有 DBA 和 USER权限
//                        .antMatchers("/data")
//                        .hasRole("DB");

                return true;
            }
        };
    }
}
